#encoding:utf8
import sys
import os
import time
import datetime


if __name__=='__main__':
	
	dir	= r'D:\me\perfectworld'

	if len(sys.argv)==1:
		os.system(r'start %s' % dir)
	else:
		arg1	= sys.argv[1].lower()
		logname	= time.strftime('%Y-%m-%d', time.localtime())+'李现民.log'
		logpath	= r'%s\工作日志\%s'%(dir, logname)

		if arg1=='offwork':
			# 检测每日工作日志是否存在
			if not os.path.exists(logpath):
				print('Sorry, can not find the daily log file: %s'%logpath)

			else:
				texts	= open(logpath, encoding='u8').readlines()
				with open(logpath, 'w', encoding= 'u8') as fout:
					index			= 0
					for line in texts:
						line		= line.strip()
						if line:
							index	+= 1	
							fout.write('%s. %s\n'%(index, line))

				os.popen(logpath)
				# 发送每日工作日志邮件
				os.system(r'pw_daily_mail.py %s'%logpath)

		elif arg1=='log':
			open(logpath, 'a', encoding='u8').close()
			os.popen(logpath)

		else:
			print('Sorry, can not recognize the input parameter: %s'%arg1)

